package ru.ssau.university.web.helper;

import java.util.ArrayList;
import java.util.List;

import ru.ssau.university.persistence.entity.Schedule;
import ru.ssau.university.persistence.entity.Subject;

public class ScheduleWrapper {
	private SubjectConverter subjectConverter;
	private List<Subject> subjects;
	private Subject choosedSubject;
	private Schedule schedule;
	
	public ScheduleWrapper(Schedule schedule, List<Subject> src) {
		this.schedule = schedule;
		this.subjects = new ArrayList<Subject>();
		for (Subject s: src) {
			subjects.add(s);
		}
		Subject emptySubject = new Subject();
		emptySubject.setTitle("---");
		this.subjects.add(emptySubject);
		if (schedule == null) {
			choosedSubject = emptySubject;
		} else {
			choosedSubject = schedule.getPlanItem().getSubject();
		}
		subjectConverter = new SubjectConverter(subjects);
	}
	
	public String getSubjectTitle() {
		if (schedule == null) {
			return "---";
		} else {
			return schedule.getPlanItem().getSubject().getTitle();
		}
	}

	public List<Subject> getSubjects() {
		return subjects;
	}

	public void setSubjects(List<Subject> subjects) {
		this.subjects = subjects;
	}

	public Subject getChoosedSubject() {
		return choosedSubject;
	}

	public void setChoosedSubject(Subject choosedSubject) {
		this.choosedSubject = choosedSubject;
	}

	public SubjectConverter getSubjectConverter() {
		return subjectConverter;
	}

	public void setSubjectConverter(SubjectConverter subjectConverter) {
		this.subjectConverter = subjectConverter;
	}

	public Schedule getSchedule() {
		return schedule;
	}

	public void setSchedule(Schedule schedule) {
		this.schedule = schedule;
	}
	
}
